package com.good.webapi.Controller;

import com.good.domain.Utils.RequestUtil;
import com.good.domain.controller.BaseController;
import com.good.domain.models.Result;
import com.good.domain.service.IUserService;
import com.good.webapi.Models.UserRegister;
import com.good.webapi.Util.SignClass;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/webapi/user")
@Api("用户接口")
public class UserController extends BaseController {

    @Autowired
    private IUserService iUserService;

    @RequestMapping(value = "info",method =RequestMethod.POST)
    public Result info(){
        return Success(iUserService.list());
    }


    @RequestMapping(value = "/add",method = RequestMethod.POST)
    /**
     * 用户注册
     *sign签名规则 md5(timestamp+signkey+mobile)
     */
    @ApiOperation(value = "注册用户",notes = "keys为手机号")

    public Result Add(@RequestBody UserRegister userRegister)
    {
        if(!SignClass.check(userRegister.timestamp,userRegister.sign,String.valueOf(userRegister.mobile))){
            return  SignError();
        }
        return Success();


    }

}
